<?php
/**
 * Created by JetBrains PhpStorm.
 * User: ishowshao
 * Date: 12-10-22
 * Time: 下午3:04
 * To change this template use File | Settings | File Templates.
 */

function func ($file, $path) {
    //echo $file, "\n";
    echo $path, "\n";
}

function dir_walk_recursive($dir, $callback, $processDir = false) {
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                $path = $dir . '/' . $file;
                if (is_dir($path)) {
                    if ($processDir) {
                        call_user_func($callback, $file, $path);
                    }
                    dir_walk_recursive($path, $callback);
                } else {
                    call_user_func($callback, $file, $path);
                }
            }
        }
        closedir($handle);
    }
}

dir_walk_recursive('.', 'func');
